package com.zhang.modules.file.entity.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhang.common.jpa.entity.DTO;
import com.zhang.modules.file.entity.CosFileInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

/**
 * A DTO for the {@link com.zhang.modules.file.entity.CosFileInfo} entity
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CosFileInfoDto implements Serializable , DTO {
    private String id;
    private String createBy;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    @Size(max = 128)
    private String bucketName;
    @Size(max = 128)
    private String objectKey;

    public CosFileInfoDto(CosFileInfo cosFileInfo) {
        setId(cosFileInfo.getId());
        setObjectKey(cosFileInfo.getObjectKey());
    }
}